package com.myfum.mobile.tetris.data.shapes
{
	import com.myfum.mobile.tetris.data.cubes.CubeData;
	import com.myfum.mobile.tetris.data.cubes.DropingCubeData;
	
	public class LLeftShapeData extends ShapeData
	{
		private const D1:int = 0;//L
		private const D2:int = 1;//J
		private const D3:int = 2;//-|
		private const D4:int = 3;//|-
		
		public function LLeftShapeData()
		{
			super();
		}
		
		override public function rotate():void{
			var dir:int = getDirection();
			var c:CubeData = cubes[2];
			switch(dir){
				case D1:
					cubes[0].x = c.x - 1;
					cubes[0].y = c.y + 1;
					cubes[1].x = c.x;
					cubes[1].y = c.y + 1;
					cubes[3].x = c.x;
					cubes[3].y = c.y - 1;
					break;
				case D2:
					cubes[0].x = c.x + 1;
					cubes[0].y = c.y + 1;
					cubes[1].x = c.x + 1;
					cubes[1].y = c.y;
					cubes[3].x = c.x - 1;
					cubes[3].y = c.y;
					break;
				case D3:
					cubes[0].x = c.x + 1;
					cubes[0].y = c.y - 1;
					cubes[1].x = c.x;
					cubes[1].y = c.y - 1;
					cubes[3].x = c.x;
					cubes[3].y = c.y + 1;
					break;
				case D4:
					cubes[0].x = c.x - 1;
					cubes[0].y = c.y - 1;
					cubes[1].x = c.x - 1;
					cubes[1].y = c.y;
					cubes[3].x = c.x + 1;
					cubes[3].y = c.y;
					break;
			}
		}
		
		private function getDirection():int{
			if(cubes[0].x == cubes[1].x && cubes[0].y < cubes[1].y){
				return D1;
			}else if(cubes[0].y == cubes[1].y && cubes[0].x < cubes[1].x){
				return D2;
			}else if(cubes[0].x == cubes[1].x && cubes[0].y > cubes[1].y){
				return D3;
			}else{
				return D4;
			}
		}
	}
}